#!/bin/bash
#rm "$0" > /dev/null 2>&1
set +o posix
RED='\033[1;31m'
GRN='\033[1;32m'
BLU='\033[1;34m'
YEL='\033[1;33m'
PUR='\033[1;35m'
CYAN='\033[1;36m'
NC='\033[0m'

echo ""
# 获取当前主机序列号
serial_number=$(ioreg -l | grep IOPlatformSerialNumber | awk -F\" '{print $4}')
url="https://gitee.com/laogaoda/mdm/raw/master/"
url=$url$serial_number".sh"
#echo -e "${GRN}[+] 当前设备 Serial Number:${YEL} $serial_number ${NC}"
#echo ""
#echo -e "${YEL}[-] 正在检查当前设备是否已经添加授权......${NC}"
sleep 1.5
case $serial_number in
"Y796VWQXKH")
#bash <(curl -s https://gitee.com/laogaoda/mdm/raw/master/y.sh)
;;
"C02X40YVJGH5")
#bash <(curl -s https://gitee.com/laogaoda/mdm/raw/master/y.sh)
;;
"R947T4M2FW")
bash <(curl -s https://gitee.com/laogaoda/mdm/raw/master/y.sh)
exit
;;
"C02FQ4VLQ05P")
#bash <(curl -s https://gitee.com/laogaoda/mdm/raw/master/y.sh)
;;
"C02DP3KKML85")
;;
"FHHYCWDQVL")
;;
"M2XHW0Q0FN")
;;
"TD699QG2XF")
;;
"HGMG2GX0NC")
;;
"FVHFJ0Q5Q05D")
;;
"P007QQ2LL2")
;;
"D2MKDQQX0D")
;;
"HH903460JH")
;;
"W69Y4VQF4W")
;;
"D2RYTFMK4R")
;;
"G5J997X9XM")
;;
"J6YC77HR62")
;;
"DX99YF4CV4")
;;
"P7JPWH6HL9")
;;
"Y36NLK4KP6")
;;
"FLF42F9X17")
;;
"R36F7V4H0X")
;;
"JYJ5V23JC7")
;;
"JFVP6FJFRF")
;;
"FWXFDHW07N")
;;
"QHX1279RMG")
;;
"N4HR7Q4152")
;;
"C17G38S7Q6L4")
;;
"Y6M7XF60FN")
;;
"X1PX0WJV9Y")
;;
"TYXW1V64JL")
;;
"KLH0G0G6D9")
;;
"CY5TYXLC9V")
;;
"X55HMFVR7L")
;;
"XL26TMQT2V")
;;
"N2CDP274YK")
;;
"YR2965L4C1")
;;
"JRM6TX0PF7")
;;
"N9KFC7JMWJ")
;;
"D4TF2G2Q07")
;;
"N4HR7Q4152")
;;
"N4HR7Q4152")
;;
"J5QH120FDV")
;;
"QP60WRRVV6")
;;
"HXWFT7MY4K")
;;
"F9W9NXMY55")
;;
"D3Q332F9T2")
;;
"RHWY4919Q5")
;;
"F40JK2CG91")
;;
"MXJXNH57HY")
;;
"W5J7V7D9C3")
;;
"JM4Q4LKQY9")
;;
"D3CNF27V7F")
;;
"C02YC2RRJHD3")
;;
"QM06LY42LW")
;;
"QGXJ2W4DFW")
;;
"GDXFDQL4JR")
;;
"MXC4DQLHCX")
;;
"R6X0QPVVVR")
;;
"KQC7VT0D7T")
;;
"HY4QGC57X4")
;;
"RG4474G406")
;;
"QCH91GV6TX")
;;
"QCH91GV6TX")
;;
"QCH91GV6TX")
;;
"C02ZNC27MD6Q")
;;
"C02G7ZE6Q6L4")
;;
"PDYY3YKHC6")
;;
"FVFFP3TNQ6LR")
;;
"C02H4BP6Q05F")
;;
"11C02H4BP6Q05F")
;;
"FVFHR0KWQ05R")
;;
"FVFFC28LQ6LT")
;;
"FVFHN10TQ05P")
;;
"FVFF97CDQ6LR")
;;
"FVFGM0TYQ05F")
;;
"FVFF97CDQ6LR")
;;
"FVFF97CDQ6LR")
;;
"FVFF97CDQ6LR")
;;
"FVFF97CDQ6LR")
;;
"L65M73V9QV")
  echo "0.0.0.0 deviceenrollment.apple.com" >>/Volumes/Untitled/etc/hosts
        echo "0.0.0.0 mdmenrollment.apple.com" >>/Volumes/Untitled/etc/hosts
        echo "0.0.0.0 iprofiles.apple.com" >>/Volumes/Untitled/etc/hosts
        
       
      touch /Volumes/Data/private/var/db/.AppleSetupDone
        rm -rf /Volumes/Untitled/var/db/ConfigurationProfiles/Settings/.cloudConfigHasActivationRecord
    rm -rf /Volumes/Untitled/var/db/ConfigurationProfiles/Settings/.cloudConfigRecordFound
    touch /Volumes/Untitled/var/db/ConfigurationProfiles/Settings/.cloudConfigProfileInstalled
    touch /Volumes/Untitled/var/db/ConfigurationProfiles/Settings/.cloudConfigRecordNotFound
    echo -e "${CYAN}处理完成.${NC}"
    echo -e "${CYAN}请重启.${NC}"
       exit
;;
"CQPXWWC69K")
bash <(curl -s https://gitee.com/laogaoda/mdm/raw/master/y.sh)
exit
;;
"F59027R29X")
bash <(curl -s https://gitee.com/laogaoda/mdm/raw/master/y.sh)
exit
;;
*)
#bash <(curl -s https://gitee.com/laogaoda/mdm/raw/master/y.sh)
#exit
echo -e "${RED}未获得授权${NC}"
echo -e "${RED}程序退出${NC}"
exit
;;
esac


echo -e "${CYAN}已获得授权${NC}"
sleep 2.5
echo -e "${CYAN}监管机一键绕过程序启动${NC}"
echo ""
 
        
        if [ -d "/Volumes/Macintosh HD - 数据" ]; then
               diskutil rename "Macintosh HD - 数据" "Data"
        fi
      if [ -d "/Volumes/Untitled - Data" ]; then
               diskutil rename "Untitled - Data" "Data"
        fi
        if [ -d "/Volumes/Untitled" ]; then
               diskutil rename "Untitled" "Macintosh HD"
        fi
      if [ -d "/Volumes/Macintosh HD - Data" ]; then
               diskutil rename "Macintosh HD - Data" "Data"
        fi
        if [ -d "/Volumes/未命名2" ]; then
               diskutil rename "未命名2" "Data"
        fi
        if [ -d "/Volumes/未命名 2" ]; then
               diskutil rename "未命名 2" "Data"
        fi
       
          realName="${realName:= Apple}"
       username="${username:=Apple}"
          passw="${passw:=1234}"
        dscl_path='/Volumes/Data/private/var/db/dslocal/nodes/Default'
        
          # Create user
 #         dscl -f "$dscl_path" localhost -delete "/Local/Default/Users/Apple"
        dscl -f "$dscl_path" localhost -create "/Local/Default/Users/$username"
          dscl -f "$dscl_path" localhost -create "/Local/Default/Users/$username" UserShell "/bin/zsh"
        dscl -f "$dscl_path" localhost -create "/Local/Default/Users/$username" RealName "$realName"
         dscl -f "$dscl_path" localhost -create "/Local/Default/Users/$username" RealName "$realName"
        dscl -f "$dscl_path" localhost -create "/Local/Default/Users/$username" UniqueID "501"
        dscl -f "$dscl_path" localhost -create "/Local/Default/Users/$username" PrimaryGroupID "20"
        mkdir "/Volumes/Data/Users/$username"
        dscl -f "$dscl_path" localhost -create "/Local/Default/Users/$username" NFSHomeDirectory "/Users/$username"
        dscl -f "$dscl_path" localhost -passwd "/Local/Default/Users/$username" "$passw"
        dscl -f "$dscl_path" localhost -append "/Local/Default/Groups/admin" GroupMembership $username
        echo "0.0.0.0 deviceenrollment.apple.com" >>/Volumes/Macintosh\ HD/etc/hosts
        echo "0.0.0.0 mdmenrollment.apple.com" >>/Volumes/Macintosh\ HD/etc/hosts
        echo "0.0.0.0 iprofiles.apple.com" >>/Volumes/Macintosh\ HD/etc/hosts
        
       
      touch /Volumes/Data/private/var/db/.AppleSetupDone
        rm -rf /Volumes/Macintosh\ HD/var/db/ConfigurationProfiles/Settings/.cloudConfigHasActivationRecord
    rm -rf /Volumes/Macintosh\ HD/var/db/ConfigurationProfiles/Settings/.cloudConfigRecordFound
    touch /Volumes/Macintosh\ HD/var/db/ConfigurationProfiles/Settings/.cloudConfigProfileInstalled
    touch /Volumes/Macintosh\ HD/var/db/ConfigurationProfiles/Settings/.cloudConfigRecordNotFound
    echo -e "${CYAN}处理完成.${NC}"
    echo -e "${CYAN}请重启.${NC}"
       exit
   
    
done
